package com.sanyuan.cloud.spring.ai.openai;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: OpenAIController
 * @Author: wuyuwei
 * @Date: 2025/4/11
 */
@RequestMapping("openai")
@RestController
public class OpenAIController {


    private final ChatClient chatClient;


    public OpenAIController(ChatClient.Builder chatClientBuilder) {
        this.chatClient = chatClientBuilder.build();
    }
    @GetMapping("/chat")
    public String chat(String prompt){
        String content = chatClient.prompt()
                .user(prompt)
                .call()
                .content();
        return content;
    }
}
